<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<%
	String menuid = request.getParameter("menuid");
	if (menuid == null) {
		menuid = "";
	}
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<jsp:include page="../inc/meta.jsp"></jsp:include>
<jsp:include page="../inc/easyui.jsp"></jsp:include>

<script type="text/javascript">
	var cbx_supermenuid = null;
	var cbx_status = null;
	var cbx_type = null;
	var menusForm = null;
	$(function() {
		menusForm = $('#menusForm').form();
		//下拉树
		cbx_supermenuid = $("#supermenuid").combotree({
			url : "menutree"
		});
		//菜单状态
		cbx_status = $("#status").combobox({
			valueField : 'id',
			textField : 'text',
			editable : false,
			panelHeight : 60,
			data : [ {
				"id" : 0,
				"text" : "正常",
				"selected" : true
			}, {
				"id" : 1,
				"text" : "禁用"
			} ]
		});

		//菜单状态
		cbx_type = $("#type").combobox({
			valueField : 'id',
			textField : 'text',
			editable : false,
			panelHeight : 60,
			data : [ {
				"id" : 0,
				"text" : "菜单",
				"selected" : true
			}, {
				"id" : 1,
				"text" : "功能"
			} ]
		});

		if ($(':input[name="menu_id"]').val().length > 0) {
			parent.$.messager.progress({
				text : '数据加载中....'
			});
			$.ajax({
				url : "getmenu",
				data : {
					menuid : $(':input[name="menu_id"]').val()
				},
				cache : false,
				dataType : "json",
				success : function(data) {
					menusForm.form('load', {
						menu_id : data.menu_id,
						menu_name : data.menu_name,
						menu_url : data.menu_url,
						menu_img : data.menu_img,
						status : data.status,
						type : data.type,
						menu_desc : data.menu_desc,
						super_menu_id : data.super_menu_id,
						sort : data.sort,
						other_url : data.other_url
					});
				}
			});

		}
	});

	var saveFun = function($dialog, treegrid, $parent) {
		menusForm.form("submit", {
			url : "addmenu",
			data : menusForm.serializeArray(),
			success : function(data) {
				var obj = eval('(' + data + ')');
				if (obj.success) {
					$dialog.dialog('destroy');
				}
				$parent.messager.alert('提示', obj.msg, 'info');
				treegrid.treegrid('reload');
			}
		});
	};

	var editF = function($dialog, treegrid, $parent) {
		menusForm.form('submit', {
			url : "editmenu",
			success : function(data) {
				var obj = eval('(' + data + ')');
				if (obj.success) {
					$dialog.dialog('destroy');
				}
				$parent.messager.alert('提示', obj.msg, 'info');
				treegrid.treegrid('reload');
			}
		});
	};
</script>
</head>
<body>
	<form method="post" class="form" id="menusForm">
		<input type="hidden" name="menu_id" value="<%=menuid%>" />
		<fieldset>
			<legend>菜单基本信息</legend>
			<table class="table" style="width: 100%;">
				<tr>
					<th>上级菜单</th>
					<td><input id="supermenuid" class="easyui-combotree"
						name="super_menu_id" type="text" style="width: 162px;" /></td>
					<th>菜单名称</th>
					<td><input name="menu_name" type="text" style="width: 162px;"
						class="easyui-validatebox" required="true" /></td>
				</tr>
				<tr>
					<th>菜单路径</th>
					<td><input name="menu_url" type="text" style="width: 162px;" />
					</td>
					<th>菜单图标</th>
					<td><select id="cc" class="easyui-combotree" name="menu_img"
						data-options="url:'<%=request.getContextPath()%>/commonData/getTreeImg'"
						style="width: 162px;"></select>
					</td>
				</tr>
				<tr>
					<th>相关路径</th>
					<td colspan="3"><input name="other_url" type="text"
						style="width: 262px;" /></td>
				</tr>
				<tr>
					<th>菜单状态</th>
					<td><input id="status" name="status" class="easyui-combobox"
						type="text" style="width: 162px;" /></td>
					<th>菜单类型</th>
					<td><input id="type" name="type" class="easyui-combobox"
						type="text" style="width: 162px;" /></td>
				</tr>
				<tr>
					<th>顺序</th>
					<td><input id="sort" name="sort" class="easyui-numberbox"
						data-options="min:0,max:9999" type="text" style="width: 50px;" />
					</td>
					<th>菜单描述</th>
					<td><input id="menu_desc" name="menu_desc" type="text"
						style="width: 162px;" /></td>
				</tr>
			</table>
		</fieldset>
	</form>
</body>
</html>
